//===============================================================================
// Microsoft patterns & practices
// Web Client Software Factory
//-------------------------------------------------------------------------------
// Copyright (C) Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//-------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;

namespace WCSFContrib.PageFlow.Tests
{
	[TestClass]
	public class PageFixture
	{
		[TestMethod]
		public void CanGetName()
		{
			Page page = new Page("MockPage", "mockpage.aspx");
			Assert.AreEqual("MockPage", page.Name);
		}

		[TestMethod]
		public void CanGetUrl()
		{
			Page page = new Page("MockPage", "mockpage.aspx");
			Assert.AreEqual("mockpage.aspx", page.Url);
		}

        [TestMethod]
        public void CanGetDefaultTransition()
        {
            string[] transitions = new string[] {"TransitionA", "TransitionB", "DefaultTransition"};
            Page page = new Page("MockPage", "mockpage.aspx", "DefaultTransition", transitions);

            Assert.AreEqual("DefaultTransition", page.DefaultTransition);
        }

        [TestMethod]
        public void CanGetTransitions()
        {
            string[] transitions = new string[] { "TransitionA", "TransitionB", "DefaultTransition" };
            Page page = new Page("MockPage", "mockpage.aspx", "DefaultTransition", transitions);

            Assert.AreEqual(3, page.Transitions.Count);
            Assert.IsTrue(page.Transitions.Contains("TransitionA"));
        }

        #region Equals implementation methods
        [TestMethod]
        public void GetHashCodeReturnsNameHashCode()
        {
            string name = "MockPage";
            Page page = new Page(name, "mockpage.aspx");
            Assert.AreEqual(name.GetHashCode(), page.GetHashCode());
        }

        [TestMethod]
        public void EqualsReturnFalseWhenComparedToNullOrOtherType()
        {
            Page page = new Page("MockPage", "mockpage.aspx");
            Assert.IsFalse(page.Equals(null));

            Assert.IsFalse(page.Equals("MockPage"));
        }

        [TestMethod]
        public void EqualsReturnsTrueWhenComparedToSameObject()
        {
            Page page = new Page("MockPage", "mockpage.aspx");

            Assert.IsTrue(page.Equals(page));
        }
        #endregion
	}
}
